package com.pyh.libray.log;

public class PStackTraceFormatter implements PLogFormatter<StackTraceElement[]> {
    @Override
    public String formatter(StackTraceElement[] data) {
        if (data == null || data.length == 0) {
            return null;
        }else if (data.length == 1){
            return "\t-"+data[0].toString();
        } else {
            StringBuilder sb = new StringBuilder("stackTrace \n");
            for (int i = 0; i < data.length - 1; i++) {
                sb.append("\t|- ").append(data[i].toString()).append("\n");
            }
            sb.append("\t - ").append(data[data.length-1]).append("\n");
            return sb.toString();
        }
    }
}
